package com.ywjt.platformbusiness.my.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ywjt.platformbusiness.R;
import com.ywjt.platformbusiness.my.model.AddressModel;

import java.util.List;


public class AddressAdapter extends BaseQuickAdapter<AddressModel.ResultDTO, BaseViewHolder> {

    public AddressAdapter(List<AddressModel.ResultDTO> data) {
        super(R.layout.item_address_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AddressModel.ResultDTO item) {
        ImageView ivSelect = helper.getView(R.id.ivSelect);
        helper.addOnClickListener(R.id.ivSelect);
        helper.addOnClickListener(R.id.tvEdit);


        helper.setText(R.id.tvName,item.getName());
        helper.setText(R.id.tvPhone,item.getPhone());
        helper.setText(R.id.tvaddress,item.getAddress()+" "+item.getDetailAddress());
        if(item.getIsDefault()==1){
            ivSelect.setImageResource(R.mipmap.icon_cart_child_selected);
            helper.setText(R.id.tvIsdefault,"默认地址");
        }else {
            helper.setText(R.id.tvIsdefault,"设置默认");
            ivSelect.setImageResource(R.mipmap.icon_cart_child_unselected);
        }
    }
}
